// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

/**
 * 动态加载资源
 */

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    
    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        let self = this;
        this.node.on('touchstart', () => {
            cc.resources.load('img/qiaozhi', cc.SpriteFrame, function(err, priteFrame){
                if(err){
                    cc.log(err)
                    return;
                }
                self.node.getComponent(cc.Sprite).spriteFrame = <cc.SpriteFrame>  priteFrame;

                cc.find('Canvas/提示框').active = true;
            })
        })

        // cc.resources.loadDir('img/', cc.SpriteFrame, function(err, assets: [cc.SpriteFrame]){
        //     console.log(assets, '--')
        // })
    }

    start () {

    }

    reset(){
        let self = this;
        cc.resources.load('img/bg', cc.SpriteFrame, function(err, priteFrame){
            if(err){
                cc.log(err)
                return;
            }
            self.node.getComponent(cc.Sprite).spriteFrame = <cc.SpriteFrame>  priteFrame;
        })
    }

    // update (dt) {}
}
